﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/AdminCP/Views/Shared/ViewMasterPage1.Master"
    Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <table id="listNhanKhau">
    </table>
    <div id="pagerNhanKhau">
    </div>
    <script type="text/javascript">
        $(function () {
            var grid = $("#listNhanKhau");
            grid.jqGrid({
                url: '<%=Url.Action("Get_List_NhanKhau", "GiaDinhCongGiao", new {id=ViewData["MAHOGIADINH"]}) %>',
                datatype: 'json',
                mtype: 'POST',
                colNames: [
                        '#',
                        '',
                        'Tên Thánh',
                        'Họ và Tên Đệm',
                        'Tên',
                        'Giới Tính',
                        'Quan Hệ'
                    ],
                colModel: [
                //{ name: 'Id', index: 'Id', width: 40, align: 'center', sortable: true, key: true, searchoptions: { sopt: ['eq', 'ne', 'lt', 'le', 'gt', 'ge']} },
                //{ name: 'Name', index: 'Name', width: 150, align: 'left', sortable: true, searchoptions: { sopt: ['cn','bw', 'bn', 'nc']} },
                {name: 'MANHANKHAU', index: 'MANHANKHAU', width: 150, align: 'left', hidden: true, key: true },
                { name: 'TATHE', index: 'TATHE', width: 30, align: 'center', sortable: false, search: false },
                { name: 'TENTHANH', index: 'TENTHANH', width: 150, align: 'left', sortable: true, searchoptions: { sopt: ['cn','bw', 'bn', 'nc']} },
                { name: 'HOVATENDEM', index: 'HOVATENDEM', width: 150, align: 'left', sortable: true, searchoptions: { sopt: ['cn','bw', 'bn', 'nc']} },
                { name: 'TEN', index: 'TEN', width: 150, align: 'left', sortable: true, searchoptions: { sopt: ['cn','bw', 'bn', 'nc']} },
                { name: 'GIOITINH', index: 'GIOITINH', width: 150, align: 'left', sortable: true, search: false },
                { name: 'QUANHE', index: 'QUANHE', width: 150, align: 'left', sortable: false, search: false }
                ],
                jsonReader: {
                    root: "rows",
                    page: "page",
                    total: "total",
                    records: "records",
                    repeatitems: false,
                    userdata: "userdata"
                },

                multiselect: true,
                multiboxonly: true,
                pager: $("#pagerNhanKhau"),
                toppager: true,
                autowidth: true,
                rowNum: 15,
                rowList: [10, 15, 20, 30, 60],
                sortname: 'TEN',
                sortorder: 'asc',
                viewrecords: true,
                height: 'auto',
                caption: '',
                beforeRequest: function () {
                    $('.jqgrid-overlay').fadeIn();
                },
                gridComplete: function () {
                    $('.jqgrid-overlay').fadeOut();
                }
            })
        .navGrid('#pagerNhanKhau', { view: false, del: false, add: false, edit: false, searchtext: 'Tìm kiếm', cloneToTop: true },
                {}, // default settings for edit
                {}, // default settings for add
                {}, // delete instead that del:false we need this
                {closeOnEscape: true, multipleSearch: true, closeAfterSearch: true }, // search options
                {} /* view parameters*/
        );

            grid.jqGrid('navGrid', '#ptoolbar', { del: false, add: false, edit: false, search: false });
            grid.jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false });


            grid.jqGrid('navButtonAdd', '#' + grid[0].id + '_toppager_left', { // "#listNhanKhau_toppager_left"
                caption: "",
                buttonicon: 'ui-icon-disk',
                onClickButton: function () {
                    var selrows = grid.getGridParam("selarrrow");
                    if (selrows != null) {
                        if (selrows.length > 1) {
                        }
                        else if (selrows.length == 0) {
                        }
                        else {
                            var url = '<%=Url.Action("ChuyenChuHo", "GiaDinhCongGiao", new { id1=ViewData["MAHOGIADINH"],id2=ViewData["MACHUHO"],id3="ID" })%>';
                            window.location = url.replace("ID", selrows);
                        }
                    }

                }
            });

            // remove some double elements from one place which we not need double
            var topPagerDiv = $('#' + grid[0].id + '_toppager')[0];         // "#listNhanKhau_toppager"
            $("#edit_" + grid[0].id + "_top", topPagerDiv).remove();        // "#edit_listNhanKhau_top"
            $("#del_" + grid[0].id + "_top", topPagerDiv).remove();         // "#del_listNhanKhau_top"
            $("#search_" + grid[0].id + "_top", topPagerDiv).remove();      // "#search_listNhanKhau_top"
            $("#refresh_" + grid[0].id + "_top", topPagerDiv).remove();     // "#refresh_listNhanKhau_top"
            $("#" + grid[0].id + "_toppager_center", topPagerDiv).remove(); // "#listNhanKhau_toppager_center"
            $(".ui-paging-info", topPagerDiv).remove();

            var bottomPagerDiv = $("div #pagerNhanKhau")[0];
            $("#add_" + grid[0].id, bottomPagerDiv).remove();               // "#add_listNhanKhau"

        });
     
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderCss" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderScript" runat="server">
</asp:Content>
